package cn.wynu.controller;

import cn.wynu.entit.User;
import cn.wynu.mapper.UserMapper;
import cn.wynu.mode.ChangePassword;
import cn.wynu.mode.RegisterUser;
import cn.wynu.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/auth")
@Slf4j
public class AuthController {
    @Autowired
    UserService userService;

    @PostMapping("/register")
    public String register(@RequestBody RegisterUser user) {
        return userService.registerUser(user);
    }

    @PostMapping("/login")
    public String login(@RequestBody RegisterUser user) {
        return userService.login(user);
    }

    @PutMapping("/password")
    public String changePwd(@RequestBody ChangePassword changePassword) {
        return userService.changePassword(changePassword);
    }
}
